
var boxes = [];
showBox = function (box,focusobj, caller, e) {
	caller.blur();	
	//new Event(e).stop ();
	box=$(box);
	if (!box) return;
	if ($(caller)) box._caller = $(caller);
	if (!boxes.contains (box)) {
		boxes.include (box);
		//box.addEvent ('click', function (e) {/*new Event(e).stop ();*/});
	}
	
	if (box.getStyle('display') == 'none') {
		box.setStyles({
			display: 'block',
			opacity: 0
		});
	}
	if (box.status == 'show') {
		//hide
		box.status = 'hide';
		var fx = new Fx.Style (box,'opacity');
		fx.stop();
		fx.start (box.getStyle('opacity'), 0);
		if (box._caller) box._caller.removeClass ('show');
	} else {
		boxes.each(function(box1){
			if (box1!=box && box1.status=='show') {
				box1.status = 'hide';
				var fx = new Fx.Style (box1,'opacity');
				fx.stop();
				fx.start (box1.getStyle('opacity'), 0);
				if (box1._caller) box1._caller.removeClass ('show');
			}
		},this);
		box.status = 'show';
		var fx = new Fx.Style (box,'opacity',{onComplete:function(){if($(focusobj))$(focusobj).focus();}});
		fx.stop();
		fx.start (box.getStyle('opacity'), 1);
		
		if (box._caller) box._caller.addClass ('show');
	}
}

//close all open window if click out site
/*
document.addEvent ('click', function (e) {
	if (e.button != 0) return; // not left click
	boxes.each(function(box){
		if (box.status=='show') {
			box.status = 'hide';
			var fx = new Fx.Style (box,'opacity');
			fx.stop();
			fx.start (box.getStyle('opacity'), 0);
			if (box._caller) box._caller.removeClass ('show');
		}
	},this);
});
*/